<?php

// Load environment config
$envConfig = require (dirname(__FILE__) . '/' . ENVIRONMENT . '/extra.php');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$main = array(
    'id' => 'propsage',
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '../',
    'name' => 'Prestige',
    // preloading 'log' component
    'preload' => array('log', 'maintenanceMode'),
    // autoloading model and component classes
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.extensions.*',
        'application.widgets.*',
    ),
	'modules' => array(
		'account' => array('class' => 'common.modules.account.AccountModule'),
		// 'transaction' => array('class' => 'common.modules.transaction.TransactionModule'),
		// 'contact' => array('class' => 'common.modules.contact.ContactModule'),
		// 'calendar' => array('class' => 'common.modules.calendar.CalendarModule'),
		// 'documents' => array('class' => 'common.modules.documents.DocumentsModule'),
  //       'projects' => array('class' => 'common.modules.projects.ProjectsModule'),
  //       'messages' => array('class' => 'common.modules.messages.MessagesModule'),
  //       'admin' => array('class' => 'application.modules.admin.PrestigeAdminModule'),
  //       'reports' => array('class' => 'common.modules.reports.ReportsModule'),
		// 'properties' => array('class' => 'common.modules.properties.PropertiesModule'),
		// 'leases' => array('class' => 'common.modules.leases.LeasesModule'),
		// 'order' => array('class' => 'common.modules.order.OrderModule'),
		'tickets' => array(
			'class' => 'common.modules.tickets.TicketsModule',
			'defaultController' => 'admin'
		)
	),
    'controllerMap' => array(
        'minify' => 'common.lib.minScript.controllers.ExtMinScriptController',
    ),
    'defaultController' => 'transaction',
    // application components
    'components' => array(
        'authManager' => array(
            'class' => 'PsDbAuthManager',
            'assignmentTable' => 'user_auth_assignment',
            'itemTable' => 'user_auth_item',
            'itemChildTable' => 'user_auth_item_child',
        ),
        'clientScript' => array(
            'class' => 'PsClientScript',
            'version' => version(),
            'scriptMap' => array(
//                'jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js',
//                'jquery.min.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
//                'jquery-ui.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js',
//                'jquery-ui.min.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js',
                'jquery-ui.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.js',
                'jquery-ui.min.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js',
                'jquery-ui.css' => false,
            )
        ),
        'minScript' => array(
            'class' => 'common.lib.minScript.components.ExtMinScript',
            'controllerID' => 'minify',
            'groupMap' => array(
            // not used in development mode
            )
        ),
		'excel' =>array(
			'class' => 'common.lib.phpexcel.Classes.PHPExcel',
		),
		'sanitizer' => array(
			'class' => 'PsInputSanitizer',
			'cleanGet' => false,
			'cleanPost' => true
		),
		'assetManager' => array(
			'class' => 'PsAssetManager',
//			'linkAssets' => YII_DEBUG
			'linkAssets' => false
		),
//        'maintenanceMode' => require dirname(__FILE__) . '/maintenance.php',
        'systemConfig' => array(
            'class' => 'PsSystemConfig',
        ),
        'user' => array(
            'class' => 'PsWebUser', // use custom CWebUser class
            'allowAutoLogin' => true, // enable cookie-based authentication
            'autoRenewCookie' => true,
            'loginUrl' => '/account/login',
        ),
        'mailer' => array(
            'class' => 'common.lib.Mailer',
        ),
        // uncomment the following to enable URLs in path-format
        'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => array(
				// REST patterns
				array('rest/<model>Api/list', 'pattern' => 'api/<model:\w+>', 'verb' => 'GET'),
				array('rest/<model>Api/view', 'pattern' => 'api/<model:\w+>/<id:\w+>', 'verb' => 'GET'),
				array('rest/<model>Api/update', 'pattern' => 'api/<model:\w+>/<id:\w+>', 'verb' => 'PUT'),
				array('rest/<model>Api/delete', 'pattern' => 'api/<model:\w+>/<id:\w+>', 'verb' => 'DELETE'),
				array('rest/<model>Api/create', 'pattern' => 'api/<model:\w+>', 'verb' => 'POST'),
                // Standard URL rules
                '<module:\w+>/<controller:\w+>/<id:\d+>'=>'<module>/<controller>/view',
                '<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<module>/<controller>/<action>',
                '<module:\w+>/<controller:\w+>/<action:\w+>'=>'<module>/<controller>/<action>',
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            ),
        ),
		'userStorage' => array(
			'class' => 'PsUserStorage'
		),
		'agencyStorage' => array(
			'class' => 'PsUserStorage',
			'mode' => 'Agency'
		),
		'errorHandler' => array(
			// use 'site/error' action to display errors
			'errorAction' => '/site/error',
		),
    ),
	'params' => array(
		'creditExpiryLimit' => 365, //days
		'referralBonus' => 5.00,
		'signupBonus' => 7.00,
		'videoPlaybackLimit' => 3,
		// Paypal sandbox settings
		'paypalSandboxEmail' => 'cform_1302059987_biz@smartvirtualoffice.com.sg',
		'paypalSandboxUrl' => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
		// Real Paypal settings
		'GSTRate' => 0, // 7.00%
		'paypalEmail' => 'paypal@propsage.com',
		'paypalUrl' => 'https://www.paypal.com/cgi-bin/webscr',
	),
);


//merge both configurations
return CMap::mergeArray($main, $envConfig);